package org.wadael.waverobotfrmwrk.advanced.example.workers;

import java.util.Date;

import org.wadael.waverobotfrmwrk.advanced.Command;
import org.wadael.waverobotfrmwrk.advanced.RobotWorker;
import org.wadael.waverobotfrmwrk.utils.BlipUtils;

import com.google.wave.api.Blip;
import com.google.wave.api.event.Event;
import com.google.wave.api.impl.EventMessageBundle;


/**
 * A worker to display some info about the wavelet.
 * For example the ID so to avoid to go into the page source of the wave application to find it. 
 * 
 * @author jerome/Wadaël
 *
 */
public class WaveInformationWorker implements RobotWorker {

	@Override
	public boolean doWork(EventMessageBundle bundle, Blip blip, Event event, String parameters) {
		StringBuffer sb = new StringBuffer(100);
		sb.append("\n");
		sb.append("\nWavelet ID is ");
		sb.append( blip.getWavelet().getWaveId());
		sb.append("\n");
		sb.append("\n");
		
		sb.append( "\nIt has been created by " );
		sb.append( blip.getWavelet().getCreator() );
		sb.append( " (on " );
		sb.append( new Date( blip.getWavelet().getCreationTime() ).toString() );
		sb.append( ")" );
		
		sb.append("\n");
		sb.append( "\nIt has " );
		sb.append(blip.getWavelet().getParticipants().size() );
		sb.append( " participants\n" );
		BlipUtils.createChildBlip(blip, sb.toString());
		return true;
		
		// TODO add more info.
	}

	@Override
	public String getDescription() {
		return "Displays some technical informations about the wavelet: id, creator and some more.";
	}

	@Override
	public String getInstruction() {
		return "waveInfo";
	}

	@Override
	public boolean areCommandsToClean() {
		return false;
	}
	
	@Override
	public String getReplacingValue(Command c, EventMessageBundle bundle, Blip blip, Event event) {
		return null;	
	}
	

}
